﻿using System;
using Core.Library;
using DataObject.Article;
using DataObject.Category;
using DataObject;

public partial class Controls_Article_Highlight : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
            ListTopHighlight();
    }

    private void ListTopHighlight()
    {
        var lstArticle = ArticleController.Article_GetTopHighlight(SettingValues.PageSize_5);
        if (lstArticle.Count > 0)
        {
            var categoryName = CategoryController.GetCategoryName(lstArticle[0].CategoryId);
            var articleHref  = UrlHelpers.ArticleDetail(categoryName, ConvertUtility.ToInt32(lstArticle[0].ArticleId), lstArticle[0].Title);

            var imgHref  = string.Format("{0}/Thumb.ashx?Id={1}&tId={2}&Size=200", Constants.ThumbImage, lstArticle[0].ArticleId, (int)CategoryType.Article);
            ltImage.Text = string.Format("<center><a href=\"{0}\"><img src=\"{1}\" alt=\"\" style=\"margin-top: 10px\" /></a></center>", articleHref, imgHref);

            rptHighlight.DataSource = lstArticle;
            rptHighlight.DataBind();
        }
    }
}
